package com.woniuxy.controller;


import com.woniuxy.entity.Department;
import com.woniuxy.entity.ShopOrders;
import com.woniuxy.service.OrderService;
import com.woniuxy.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
public class orderController {

    // 生成订单

    @Autowired
    OrderService orderService;

    // 获取所有的科室
    @PostMapping("/insert")  // order/insert
    public ResponseResult<ShopOrders> insertOrderMedical(@RequestBody ShopOrders shopOrders){
        System.out.println("shopOrders"+shopOrders);
        ShopOrders shopreturn = orderService.insertOrderMedical(shopOrders);
        System.out.println("order生成的uuid-controller"+shopreturn);
        if(shopreturn!=null){
            return ResponseResult.success("新增成功",shopreturn);
        }else{
            return ResponseResult.fail(500,"新增订单出错");
        }
    }

    @GetMapping("/selectByuserIdForUnpay")  // order/selectByuserIdForUnpay
    public ResponseResult<List<ShopOrders>> selectByuserIdForUnpay(@RequestParam("userId") Integer userId
                                                                   ,@RequestParam("status") Integer status,@RequestParam("pay_type") Integer pay_type ){
        System.out.println("测试"+userId+status+pay_type);
        List<ShopOrders> shoporders=  orderService.selectByuserIdForUnpay(userId,status,pay_type);
        return ResponseResult.success(shoporders);
    }
}
